package com.typ.member.web.api;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.typ.member.common.model.Response;
import com.typ.member.common.model.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


/**
 * 会员卡信息API
 *
 * @author heran
 * @version 1.0, 2019-05-09 18:09
 */
@RestController
@Slf4j
@RequestMapping("/user")
public class UserApiController {

    @PostMapping("/login")
    public Response login() {
        String token = "admin-token";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("token", token);
        return ResponseUtil.createSuccess(jsonObject.toJSONString());
    }


    @PostMapping("/logout")
    public Response logout() {
        return ResponseUtil.createSuccess("success");
    }

    @GetMapping("/info")
    public Response info() {
        JSONObject jsonObject = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        jsonArray.add("'admin'");
        jsonObject.put("roles", jsonArray);
        jsonObject.put("introduction", "I am a super administrator");
        jsonObject.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        jsonObject.put("name", "Super Admin");

        return ResponseUtil.createSuccess(jsonObject.toJSONString());
    }

}
